home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / quicktime / capturing / simplevideoout / cvideooutput.h < prev    next >
Encoding:
Text File  |  2000-09-28  |  6.4 KB  |  145 lines

  1. /*
  2.     File:        CVideoOutput.h
  3.     
  4.     Description: SimpleVideoOut is an example of using QuickTimes FireWire video
  5.                  output component to play a DV stream (.dv movie) out to a DV Camera.
  6.                  This code is based on VidOutApp originally written by Jay Lloyd, Casey King
  7.                  and Adrienne Wang.
  8.  
  9.     Author:        era
  10.  
  11.     Copyright:     © Copyright 2000 Apple Computer, Inc. All rights reserved.
  12.     
  13.     Disclaimer:    IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
  14.                 ("Apple") in consideration of your agreement to the following terms, and your
  15.                 use, installation, modification or redistribution of this Apple software
  16.                 constitutes acceptance of these terms.  If you do not agree with these terms,
  17.                 please do not use, install, modify or redistribute this Apple software.
  18.  
  19.                 In consideration of your agreement to abide by the following terms, and subject
  20.                 to these terms, Apple grants you a personal, non-exclusive license, under Apple’s
  21.                 copyrights in this original Apple software (the "Apple Software"), to use,
  22.                 reproduce, modify and redistribute the Apple Software, with or without
  23.                 modifications, in source and/or binary forms; provided that if you redistribute
  24.                 the Apple Software in its entirety and without modifications, you must retain
  25.                 this notice and the following text and disclaimers in all such redistributions of
  26.                 the Apple Software.  Neither the name, trademarks, service marks or logos of
  27.                 Apple Computer, Inc. may be used to endorse or promote products derived from the
  28.                 Apple Software without specific prior written permission from Apple.  Except as
  29.                 expressly stated in this notice, no other rights or licenses, express or implied,
  30.                 are granted by Apple herein, including but not limited to any patent rights that
  31.                 may be infringed by your derivative works or by other works in which the Apple
  32.                 Software may be incorporated.
  33.  
  34.                 The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
  35.                 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
  36.                 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  37.                 PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
  38.                 COMBINATION WITH YOUR PRODUCTS.
  39.  
  40.                 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
  41.                 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  42.                 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  43.                 ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
  44.                 OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
  45.                 (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
  46.                 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  47.                 
  48.     Change History (most recent first): <1> 1/28/00 initial release
  49.  
  50. */
  51.  
  52. /*
  53.     The CVideoOutput Class is very easy to use and encapsulates the basic set of functions required
  54.     to output a DV Stream over FireWire.
  55.     
  56.     To instantiate a CVideoOutput object pass it your Movie.
  57.     
  58.     Open( const unsigned char inClientNameStr[], const short inMode )
  59.         Opens the FireWire video output component, registers a client name with the component
  60.         and sets up the display mode. This method also acquires the audio media handlers for up to five
  61.         audio tracks for use later when setting up the sound device and will automatically close
  62.         a video output component if it's already open before re-instantiating a new one.
  63.     
  64.     Begin( Boolean inUseVOsdev = true, Boolean inUseVOClk = true )
  65.         Gains exclusive access to the hardware, sets up the sound output and the clock component
  66.         associated with the video output component. Begin also acquires the GWorld used by the video
  67.         output component. Both the sound and clock parameters are set to 'true' by default.
  68.     
  69.     SetEchoPort( const CGrafPtr inEchoPort = NULL )
  70.         Allows you to display video both on an external video display and in a window.
  71.         Pass in a CGrafPtr to specify a window to display video sent to the device. When video
  72.         is displayed in the window you specify, the video is displayed in the window and sent
  73.         to the normal output of the video output device. SimpleVideoOut by default turns the
  74.         EchoPort on but allows you to turn it off.
  75.     
  76.     SetSoundDevice( const Boolean inUseVOsdev = true )
  77.         This call will turn on/off the use of the video output components sound device, by
  78.         default SimpleVideoOut turns it on. Passing in 'true' will set up the use of the
  79.         video output components sound device and also sets up the clock component which is used
  80.         to synchronize video and sound for a movie to the rate of the display. Passing in 'false'
  81.         will use the default sound device and default clock.
  82.     
  83.     End( void )
  84.         Relinquishes exclusive access to the hardware. Also called by Close().
  85.     
  86.     Close( void )
  87.         Closes the component instance and zeros the object. It is also called by the objects destructor.
  88.         
  89.     GetGWorld( void )
  90.         Returns a pointer to the graphics world used by a video output component.
  91.         
  92.     GetError( void )
  93.         Returns the last return code generated by the system.
  94. */
  95.  
  96. #ifndef __CVIDEOOUTPUT_H__
  97.     #define __CVIDEOOUTPUT_H__
  98.  
  99. #include <QuickTimeComponents.h>
  100. #include <MediaHandlers.h>
  101.  
  102. namespace dts {
  103.  
  104. const UInt8 kMaxAudioTrax = 5;
  105.  
  106. enum {
  107.     eAudioRate48khz = (long)0xBB800000, /* 48000.00000 in fixed-point */
  108.     eAudioRate44khz = (long)0xAC440000, /* 44100.00000 in fixed-point */
  109.     eAudioRate32khz = (long)0x7D000000  /* 32000.00000 in fixed-point */
  110. };
  111.  
  112. class CVideoOutput {
  113.     public:
  114.         CVideoOutput( const Movie inMovie );
  115.         ~CVideoOutput() { Close(); };
  116.         
  117.         OSErr         Open( const unsigned char inClientNameStr[], const short inMode );
  118.         void         Close( void );        
  119.         
  120.         OSErr         Begin( Boolean inUseVOsdev = true, Boolean inUseVOClk = true );
  121.         void        End( void );        
  122.                 
  123.         OSErr         SetEchoPort( const CGrafPtr inEchoPort = NULL );
  124.         OSErr         SetSoundDevice( const Boolean inUseVOsdev = true );
  125.         
  126.         GWorldPtr     GetGWorld( void ) const { if ( mVideoOutputInUse == true ) return mVOutputGWorld; else return NULL; };
  127.         OSErr        GetError( void ) const { return rc; };
  128.  
  129.     private:
  130.         Movie                    mMovie;
  131.         GWorldPtr                mVOutputGWorld;
  132.         Component                mVOutputComponent;
  133.         QTVideoOutputComponent     mVOutputInstance;
  134.         Component                mDefaultSoundOutComponent;
  135.         Component                mSoundOutComponent;
  136.         ComponentInstance        mMovieClockInstance;
  137.         MediaHandler             mAudioMediaHandler[kMaxAudioTrax];
  138.         UInt8                    mNumberAudioTracks;
  139.         Boolean                    mVideoOutputInUse;
  140.         ComponentResult            rc;
  141. };
  142.  
  143. } // namespace
  144.  
  145. #endif // __CVIDEOOUTPUT_H__